<template>
  <a-popconfirm
    v-if="!disabled"
    :title="`是否确认${status ? ctext : otext}?`"
    ok-text="确认"
    cancel-text="取消"
    @confirm="confirm"
  >
    <a-button type="link" :primary="!Boolean(status)" :danger="Boolean(status)">{{ status ? ctext : otext }}</a-button>
  </a-popconfirm>
  <a-button v-else type="link" disabled>{{ status ? ctext : otext }}</a-button>
</template>

<script lang="ts" setup>
import { toRefs } from 'vue'
const emits = defineEmits(['confirm'])
const props = defineProps<{
  disabled?: boolean
  otext: string
  ctext: string
  status: number
}>()

const { disabled = false, otext = '启用', ctext = '禁用' } = toRefs(props)

function confirm() {
  emits('confirm')
}
</script>

<style lang="less"></style>
